<template>
  <el-container>
    <div class="Jump">
      <el-button
        @click="navigator"
        style="margin-right: 20px"
        icon="el-icon-back"
        type="primary"
        v-if="returnUrl"
        >返回上一页</el-button
      >
    </div>
    <!-- <el-header>
       <el-button @click="$router.push('/foodSafety/archives/archives')"    style="margin-right: 20px" icon="el-icon-back" type="primary"
            >返回上一页</el-button
          >
          <rz-height></rz-height>
      <div class="title">
        {{data.operAtorName||data.unitname}}
      </div>
      <rz-height></rz-height>
      <el-row :gutter="20">
        <el-col :span="6">统一社会信用代码:{{data.identify}}</el-col>
        <el-col :span="6" v-if="data.newlicenseno">许可证编号:{{data.newlicenseno}}</el-col>
      </el-row>
      <rz-height></rz-height>
      <el-row>
        <el-col :span="24">地址:{{data.productionAddress||data.address}}</el-col>
      </el-row>
    </el-header>
     <el-header> -->
    <el-header>
      <!-- <el-button @click="$router.push('/foodSafety/archives/archives')"    style="margin-right: 20px" icon="el-icon-back" type="primary"
            >返回上一页</el-button
          > -->
      <rz-height></rz-height>
      <div class="title">
        {{ data.operAtorName || data.unitname }}
      </div>
      <rz-height></rz-height>
      <div>
        <el-tag>{{ data.districtName + "—" + data.streetName }}</el-tag>
        <el-tag type="warning"
          >{{ data.bodyindustry
          }}{{ data.bodyindustryremarks ? "--" + data.bodyindustryremarks : "" }}</el-tag
        >
        <el-tag type="success" v-if="data.isspecialfood == 1">特殊食品</el-tag>
        <el-tag type="success" v-if="data.isnetbusiness == 1">网络经营</el-tag>
        <el-tag type="success" v-if="data.islargerkitchen == 1">中央厨房</el-tag>
        <el-tag type="success" v-if="data.iscollectivedistribution == 1"
          >集体用餐配送</el-tag
        >
        <el-tag type="success" v-if="data.ishealthfood == 1">保健食品</el-tag>
        <el-tag type="success" v-if="data.isbbf == 1">婴幼儿配方食品</el-tag>
        <el-tag type="success" v-if="data.isspecialmedicine == 1"
          >特殊医学用途配方食品</el-tag
        >
        <el-tag type="success" v-if="data.remark">{{ data.remark }}</el-tag>
        <el-tag type="success" v-if="data.typeA">{{ data.typeA }}</el-tag>
      </div>
      <rz-height></rz-height>
      <el-row :gutter="20">
        <el-col :span="8">统一社会信用代码：{{ data.identify }}</el-col>
        <el-col :span="12">营业执照名称：{{ data.unitname }}</el-col>
      </el-row>
      <rz-height></rz-height>

      <el-row :gutter="20">
        <el-col :span="8" v-if="data.newlicenseno"
          >许可证编号：{{ data.newlicenseno }}</el-col
        >
        <el-col :span="12">经营者名称：{{ data.operAtorName }}</el-col>
      </el-row>
      <rz-height></rz-height>

      <el-row :gutter="20">
        <el-col :span="8">创建日期：{{ data.createDateTimeStr }}</el-col>
        <el-col :span="12">地址：{{ data.productionAddress || data.address }}</el-col>
      </el-row>
      <div class="qr_code">
        <vue-qr :text="url" ref="Qrcode" :margin="0" :logoScale="0.3" :size="90"></vue-qr>

        <el-button @click="getQrCode()" size="mini" style="margin-top: 10px"
          >下载食安码</el-button
        >
      </div>
      <div style="position: absolute; right: 3%; top: 20%">
        <a
          @click="record = true"
          size="mini"
          style="margin-top: 10px; text-decoration: underline"
          >操作记录</a
        >
      </div>
    </el-header>
    <el-container class="content">
      <el-aside width="200px">
        <el-menu
          :default-active="defaultActive"
          class="el-menu-vertical-demo"
          router
          active-text-color="#ffffff"
          text-color="#000"
        >
          <el-menu-item :index="`${item.route}`" v-for="item in list" :key="item.id">
            <span slot="title">{{ item.title }}</span>
          </el-menu-item>
          <!-- <el-menu-item index="2">
            <span slot="title">安全事故</span>
          </el-menu-item> -->
          <!-- <el-menu-item index="2">
            <span slot="title">主体责任</span>
          </el-menu-item>
          <el-menu-item index="2">
            <span slot="title">投诉举报</span>
          </el-menu-item>
          <el-menu-item index="2">
            <span slot="title">监督执法</span>
          </el-menu-item>
          <el-menu-item index="2">
            <span slot="title">食品抽检</span>
          </el-menu-item> -->
        </el-menu>
      </el-aside>
      <el-main>
        <router-view></router-view>
      </el-main>
    </el-container>

    <el-dialog title="操作记录" :visible.sync="record" width="30%">
      <el-timeline>
        <el-timeline-item
          v-for="(activity, index) in dataList"
          :key="index"
          :timestamp="activity.updateTime"
        >
          {{ activity.updateContent }}
        </el-timeline-item>
      </el-timeline>
      <div class="center" v-if="dataList.length == 0">暂无操作记录</div>
      <span slot="footer" class="dialog-footer">
        <el-button @click="record = false">关 闭</el-button>
      </span>
    </el-dialog>
  </el-container>
</template>
<script>
import { CompanyMainPageInfo, changeRecordList } from "@/api/modules/enterprise";
import vueQr from "vue-qr";
export default {
  components: {
    vueQr,
  },
  // props:[],
  // 页面加载
  created() {
    this.getCompanyMainPageInfo();
    if (this.$route.query.url) {
      this.returnUrl = this.$route.query.url;
    }
    if(process.env.VUE_APP_TYPE=='zjg'){
        this.list.push({
          title: "明厨亮灶",
          id: 6,
          route: "/interpretation/kitchen",
        })
    }
  },
  // 页面加载完成
  mounted() {},
  //实例销毁之前
  beforeDestroy() {},
  //实例销毁后
  destroyed() {},
  data() {
    return {
      url: `https://spaq.suzhou.gov.cn/ssa-publicity/#/publicity?id=${sessionStorage.getItem(
        "interpretation"
      )}`,
      list: [
        {
          title: "精准画像",
          id: 0,
          route: "/interpretation/portrait",
        },
        {
          title: "安全事故",
          id: 1,
          route: "/interpretation/security",
        },
        {
          title: "主体责任",
          id: 2,
          route: "/interpretation/homeRespon",
        },
        {
          title: "投诉举报",
          id: 3,
          route: "/interpretation/complaints",
        },
        {
          title: "日常监督",
          id: 4,
          route: "/interpretation/supervise",
        },
        {
          title: "食品抽检",
          id: 5,
          route: "/interpretation/spotCheck",
        },
        
      ],
      defaultActive: "/interpretation/analysis",
      data: {},
      returnUrl: false,
      record: false,
      dataList: [],
    };
  },
  // 方法
  methods: {
    getCompanyMainPageInfo() {
      CompanyMainPageInfo({
        params: {
          id: sessionStorage.getItem("interpretation"),
        },
      }).then((res) => {
        this.data = res.data;
      });
      changeRecordList({
        id: sessionStorage.getItem("interpretation"),
        pageIndex: 1,
        pageSize: 100,
        type: "",
      }).then((res) => {
        this.dataList = res.data.list;
      });
    },
    navigator() {
      this.$router.replace(this.returnUrl);
    },
    getQrCode() {
      const iconUrl = this.$refs.Qrcode.$el.src;
      // console.log(iconUrl);
      // this.$downloadFiles(iconUrl);

      const a = document.createElement("a");
      const event = new MouseEvent("click");
      a.download = "食安码" + new Date().getTime(); //下载后文件名
      a.href = iconUrl;
      a.dispatchEvent(event);
    },
  },
  // 监听属性
  watch: {
    $route(to, from) {
      this.defaultActive = to.path;
      if (
        to.path != "/interpretation/portrait" &&
        to.path != "/interpretation/security" &&
        to.path != "/interpretation/complaints" &&
        to.path != "/interpretation/supervise" &&
        to.path != "/interpretation/spotCheck" &&
        to.path != "/interpretation/kitchen"
      ) {
        this.defaultActive = "/interpretation/homeRespon";
      }
    },
  },
  // 计算属性
  computed: {},
};
</script>

<style lang="scss" scoped>
.el-container {
  height: calc(100% - 130px);
  .el-header {
    padding: 20px;
    height: auto !important;
    position: relative;
    .title {
      font-size: 25px;
      font-weight: 700;
    }

    .el-tag {
      margin-right: 10px;
    }
    background: $default;
    color: #ffffff;
    .qr_code {
      position: absolute;
      right: 10%;
      top: 20%;
      display: flex;
      flex-direction: column;
    }
  }
  .Jump {
    padding: 10px;
    background: #2e40d1;
  }
  .el-aside {
    /deep/ .el-menu {
      border-right: none;
      .is-active {
        background-color: $default;
        opacity: 0.7;
      }
    }
  }

  .el-main {
    background-color: #f2f2f2;
  }
}
// .content{
//   height:calc(100% - 120px);
// }
</style>
